#!/usr/bin/env python3
"""
Basic usage example for GSI Wiki Generator
"""

from pathlib import Path
from gsi_wiki_generator import GSIWikiGenerator, WikiConfig


def main():
    """Demonstrate basic usage of GSI Wiki Generator"""
    
    # Example 1: Use default configuration
    print("Example 1: Using default configuration")
    try:
        generator = GSIWikiGenerator()
        progress = generator.get_progress_report()
        print(f"Progress: {progress['completed_questions']}/{progress['total_questions']} questions")
    except Exception as e:
        print(f"Error with default config: {e}")
    
    # Example 2: Custom configuration
    print("\nExample 2: Using custom configuration")
    config = WikiConfig(
        input_directory="/home/docker/comgsi/tutorial/comGSIv3.7_EnKFv1.3/src/comGSI-wiki",
        output_directory="./custom_output",
        max_results=15,
        min_score=0.1
    )
    
    try:
        generator = GSIWikiGenerator(config)
        
        # Check progress
        progress = generator.get_progress_report()
        print(f"Input directory: {progress['input_directory']}")
        print(f"Search progress: {progress['search_progress_percent']:.1f}%")
        print(f"Question progress: {progress['question_progress_percent']:.1f}%")
        
        # Generate wiki (this is the main operation)
        print("\nGenerating wiki...")
        wiki_file = generator.save_wiki("custom_wiki.md")
        print(f"Wiki generated: {wiki_file}")
        
    except Exception as e:
        print(f"Error: {e}")
    
    # Example 3: Progress checking
    print("\nExample 3: Progress checking and cache management")
    generator = GSIWikiGenerator()
    
    # Get detailed progress
    progress = generator.get_progress_report()
    print(f"Session ID: {progress['session_id']}")
    print(f"Last updated: {progress['last_updated']}")
    print(f"Completed searches: {progress['completed_searches']}")
    print(f"Completed questions: {progress['completed_questions']}")
    
    # Reset cache if needed (uncomment to use)
    # print("Resetting cache...")
    # generator.reset_progress_cache()
    # print("Cache reset complete")


if __name__ == "__main__":
    main()